#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<int> a;

int searchstart(int min, int max,int search){
    if (a[min]==search){
            return min;
    }
    if (a[max]==search){
            return max;
    }
    if (min>=max-1){
        
        return -1;  
    }
    
    int mid=(min+max)/2;
    if (a[mid]<search){
        return searchstart(mid+1,max,search);
    }
    else if (a[mid]>search){
        return searchstart(min,mid-1,search);
    }
    else{return mid;}
}
int main(){
    
    int count=0;
    char c;
    string ch="";
    while ((c=getchar())!='\n'){
        if (c!=' '){
            ch+=c; 
        }
        else{
            a.push_back(stoi(ch));
            ch.clear();
            count++;
            
        }
    }
    a.push_back(stoi(ch));
    count++;

    

    int search;
    std::cin>>search;
    int searchnum=searchstart(0,count-1,search);
    if (searchnum==-1){
        std::cout<<"-1, -1"<<std::endl;
        return 0;
    }
    int left=searchnum;
    while (left!=0&&a[left-1]==a[searchnum]){
        left--;
    }
    int right=searchnum;
    while (right!=count-1&&a[right+1]==a[searchnum]){
        right++;
    }
    std::cout<<left<<", "<<right<<std::endl;
    return 0;
    
}